const RPCClient = require("@alicloud/pop-core").RPCClient;
const initVodClient = (accessKeyId, accessKeySecret) => {
  let regionId = "cn-shanghai"; // 点播服务接入地域
  let client = new RPCClient({
    //填入AccessKey信息
    accessKeyId: accessKeyId,
    accessKeySecret: accessKeySecret,
    endpoint: 'http://vod.' + regionId + '.aliyuncs.com', //??为什么需要这两个参数不给阿里云vod的Node包会报错
    apiVersion: '2017-03-21'//??为什么需要这两个参数 不给阿里云vod的Node包会报错
  });
  return client;
};

const getVod = async (req, res) => {
  let client = initVodClient(
    // 这里就是传入创建rma账号的id和secret
    "LTAI5t7j6BNCdd1raEcZqxvY",
    "n8my816RDi52M2D4w6ImSp7WFaEm96",
    
  );

  const vodback = await client.request(
    "CreateUploadVideo",
    {
      Title: "test vod",
      FileName: "filename.mp4",
    },
    {}
  );
  console.log(vodback,'---- vodback ----');
  res.status(200).json({ vod: vodback });
};

module.exports = {
  getVod,
};
